home *** CD-ROM | disk | FTP | other *** search
-
- #include "main.h"
-
-
- //------------------------------------------------------------------
- // Name: OFFSCREEN()
- // Desc: konstruktor
- //------------------------------------------------------------------
- OFFSCREEN::OFFSCREEN()
- {
-
- RenderToSurface = NULL ;
- DynamicTexture = NULL;
- TextureSurface = NULL;
-
- Width = 256;
- Height = 256;
-
- }
-
- //------------------------------------------------------------------
- // Name: ~OFFSCREEN()
- // Desc: destruktor
- //------------------------------------------------------------------
- OFFSCREEN::~OFFSCREEN()
- {
-
- if( RenderToSurface != NULL )
- RenderToSurface->Release();
-
- if( DynamicTexture != NULL )
- DynamicTexture->Release();
-
- if( TextureSurface != NULL )
- TextureSurface->Release();
-
- }
-
-
- //------------------------------------------------------------------
- // Name: Initialize()
- // Desc: inicializacia textur a povrchov
- //------------------------------------------------------------------
- void OFFSCREEN::Initialize()
- {
-
- LogPrint("Inicializujem Texturu pre rendering");
-
- //
- // Create our dynamic texture for use by the "render to" surface...
- //
- if (FAILED(D3DXCreateTexture( g_pd3dDevice,
- Width,
- Height,
- 1,
- D3DUSAGE_RENDERTARGET,
- D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT,
- &DynamicTexture )))
- {
- LogPrint(" Nepodarilo sa vytvorit dynamicku texturu");
- }
- else
- {
- LogPrint(" Dynamicka textura vytvorena");
- }
-
- //
- // Create an off-screen "render to" surface...
- //
- D3DSURFACE_DESC desc;
- DynamicTexture->GetSurfaceLevel( 0, &TextureSurface );
- TextureSurface->GetDesc( &desc );
-
- if (FAILED(D3DXCreateRenderToSurface( g_pd3dDevice,
- desc.Width,
- desc.Height,
- desc.Format,
- TRUE,
- D3DFMT_D16,
- &RenderToSurface )))
- {
- LogPrint(" Nepodarilo sa vytvorit povrch");
- }
- else
- {
- LogPrint(" Povrch vytvoreny");
- }
-
- //
- //Vytvorenie projekcnej matice
- //
- D3DXMatrixPerspectiveFovLH( &Projection, 45.0f,
- (float)Width / (float)Height,
- 0.1f, 100.0f );
- }
-
- //------------------------------------------------------------------
- // Name: BeginRender()
- // Desc: zaciatok render-> vycistenie bufferu
- //------------------------------------------------------------------
- void OFFSCREEN::BeginRender()
- {
-
- RenderToSurface->BeginScene( TextureSurface, NULL );
-
- g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
- D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0);
-
-
-
- }
-
- //------------------------------------------------------------------
- // Name: EndRender()
- // Desc: koniec renderu -> prezentacia dßt
- //------------------------------------------------------------------
- void OFFSCREEN::EndRender()
- {
- RenderToSurface->EndScene( 0 );
- }
-
- //------------------------------------------------------------------
- // Name: GetTexture()
- // Desc: vrati texturu do ktorej sa renderovalo
- //------------------------------------------------------------------
- LPDIRECT3DTEXTURE9 OFFSCREEN::GetTexture()
- {
- return DynamicTexture;
- }
-